package month1;

public class InvertBinaryTree226_05 {
    public static void main(String[] args) {
        System.out.println(invertTree(new TreeNode(new Integer[]{4, 2, 7, 1, 3, 6, 9})));
    }

    /**
     * 递归吧
     *
     * @param root
     * @return
     */
    static TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode left = root.left;
        root.left = invertTree(root.right);
        root.right = invertTree(left);
        return root;
    }
}
